import { defineStore } from 'pinia'
import { ref } from 'vue';
import { Home } from '@/api';

// 定义仓库--组合式
export let useMenusStore = defineStore('menu', () => {
    // state--菜单列表
    let menus = ref({});

    // action--获取菜单列表
    let obtain = async () => {
        let { status, msg, data } = await Home.menus();
        if (status === 200) {
            menus.value = data.menus;
        } else {
            ElNotification.error(msg);
        }
    }
    // 可以提前写好return
    return { menus, obtain }
});
